package com.treeman.marker.service;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;

import com.treeman.api.json.marker.MarkerJson;
import com.treeman.marker.Marker;
import com.treeman.marker.exception.MarkerNotFoundException;
import com.treeman.marker.exception.NoMarkersFoundException;

public interface MarkerService {

	@PreAuthorize("hasRole('ROLE_USER') and #markerJson.author ==  authentication.name")
	public Long addMarker(MarkerJson markerJson);

	public List<Marker> getUserMarkers(String username)
			throws NoMarkersFoundException;

	public List<MarkerJson> getUserMarkersJson(String username)
			throws NoMarkersFoundException;

	public Marker getMarkerById(Long id) throws MarkerNotFoundException;

	public MarkerJson getMarkerJsonById(Long id) throws MarkerNotFoundException;

	@PreAuthorize("hasRole('ROLE_USER') and #markerJson.author == #username")
	public Long updateMarkerJson(MarkerJson marker, String username)
			throws MarkerNotFoundException;

	@PreAuthorize("hasRole('ROLE_USER')")
	public void deleteMarker(Long id, String username)
			throws MarkerNotFoundException;
}
